package com.only4play.system.web;

import com.only4play.common.model.JsonObject;
import com.only4play.common.model.PageRequestWrapper;
import com.only4play.common.model.PageResult;
import com.only4play.productcenter.api.goods.request.GoodsCreateRequest;
import com.only4play.productcenter.api.goods.request.GoodsInStoreRequest;
import com.only4play.productcenter.api.goods.request.GoodsQueryRequest;
import com.only4play.productcenter.api.goods.request.GoodsUpdateRequest;
import com.only4play.productcenter.api.goods.response.GoodsResponse;
import com.only4play.productcenter.api.goods.service.GoodsFeignService;
import com.only4play.system.req.AgentGoodsIn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "goods")
@Schema(title = "goods")
@RequiredArgsConstructor
public class GoodsController {

  private final GoodsFeignService goodsFeignService;

  public JsonObject<String> agentGoodsIn(@RequestBody AgentGoodsIn agentGoodsIn){
    Long agentId = agentGoodsIn.getAgentId();
    GoodsInStoreRequest request = new GoodsInStoreRequest();

    return goodsFeignService.goodsInStore(request);
  }

  /**
   * findById
   */
  @GetMapping("findById/{id}")
  public JsonObject<GoodsResponse> findById(@PathVariable Long id) {
    return goodsFeignService.findById(id);
  }

  /**
   * findByPage request
   */
  @PostMapping("findByPage")
  public JsonObject<PageResult<GoodsResponse>> findByPage(
      @RequestBody PageRequestWrapper<GoodsQueryRequest> request) {
    return goodsFeignService.findByPage(request);
  }

}
